home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / tex / tex31 / inputs.lzh / webmac.tex < prev   
Text File  |  1990-04-04  |  10KB  |  206 lines

  1. % standard macros for WEB listings (in addition to PLAIN.TEX)
  2. \xdef\fmtversion{\fmtversion+WEBMAC4.0} % identifies current set of macros
  3. \parskip 0pt % no stretch between paragraphs
  4. \parindent 1em % for paragraphs and for the first line of Pascal text
  5.  
  6. \font\eightrm=cmr8
  7. \let\sc=\eightrm \let\mainfont=\tenrm
  8. \font\titlefont=cmr7 scaled\magstep4 % title on the contents page
  9. \font\ttitlefont=cmtt10 scaled\magstep2 % typewriter type in title
  10. \font\tentex=cmtex10 % TeX extended character set (used in strings)
  11.  
  12. \def\\#1{\hbox{\it#1\/\kern.05em}} % italic type for identifiers
  13. \def\|#1{\hbox{$#1$}} % one-letter identifiers look a bit better this way
  14. \def\{\hbox{\bf#1\/}} % boldface type for reserved words
  15. \def\.#1{\hbox{\tentex % typewriter type for strings
  16.   \let\\=\BS % backslash in a string
  17.   \let\'=\RQ % right quote in a string
  18.   \let\`=\LQ % left quote in a string
  19.   \let\{=\LB % left brace in a string
  20.   \let\}=\RB % right brace in a string
  21.   \let\~=\TL % tilde in a string
  22.   \let\ =\SP % space in a string
  23.   \let\_=\UL % underline in a string
  24.   \let\&=\AM % ampersand in a string
  25.   #1}}
  26. \def\#{\hbox{\tt\char`\#}} % parameter sign
  27. \def\${\hbox{\tt\char`\$}} % dollar sign
  28. \def\%{\hbox{\tt\char`\%}} % percent sign
  29. \def\^{\ifmmode\mathchar"222 \else\char`^ \fi} % pointer or hat
  30. % circumflex accents can be obtained from \^^D instead of \^
  31. \def\AT!{@} % at sign for control text
  32.  
  33. \chardef\AM=`\& % ampersand character in a string
  34. \chardef\BS=`\\ % backslash in a string
  35. \chardef\LB=`\{ % left brace in a string
  36. \def\LQ{{\tt\char'22}} % left quote in a string
  37. \chardef\RB=`\} % right brace in a string
  38. \def\RQ{{\tt\char'23}} % right quote in a string
  39. \def\SP{{\tt\char`\ }} % (visible) space in a string
  40. \chardef\TL=`\~ % tilde in a string
  41. \chardef\UL=`\_ % underline character in a string
  42.  
  43. \newbox\bak \setbox\bak=\hbox to -1em{} % backspace one em
  44. \newbox\bakk\setbox\bakk=\hbox to -2em{} % backspace two ems
  45.  
  46. \newcount\ind % current indentation in ems
  47. \def\1{\global\advance\ind by1\hangindent\ind em} % indent one more notch
  48. \def\2{\global\advance\ind by-1} % indent one less notch
  49. \def\3#1{\hfil\penalty#10\hfilneg} % optional break within a statement
  50. \def\4{\copy\bak} % backspace one notch
  51. \def\5{\hfil\penalty-1\hfilneg\kern2.5em\copy\bakk\ignorespaces}% optional break
  52. \def\6{\ifmmode\else\par % forced break
  53.   \hangindent\ind em\noindent\kern\ind em\copy\bakk\ignorespaces\fi}
  54. \def\7{\Y\6} % forced break and a little extra space
  55.  
  56. \let\yskip=\smallskip
  57. \def\to{\mathrel{.\,.}} % double dot, used only in math mode
  58. \def\note#1#2.{\Y\noindent{\hangindent2em\baselineskip10pt\eightrm#1~#2.\par}}
  59. \def\lapstar{\rlap{*}}
  60. \def\startsection{\Q\noindent{\let\*=\lapstar\bf\modstar.\quad}}
  61. \def\defin#1{\global\advance\ind by 2 \1\&{#1 }} % begin `define' or `format'
  62. \def\A{\note{See also section}} % crossref for doubly defined section name
  63. \def\As{\note{See also sections}} % crossref for multiply defined section name
  64. \def\B{\mathopen{\.{@\{}}} % begin controlled comment
  65. \def\C#1{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi % Pascal comments
  66.   \XX\hfil\penalty-1\hfilneg\quad$\{\,$#1$\,\}$\XX}
  67. \def\D{\defin{define}} % macro definition
  68. \def\E{\cdot10^} % exponent in floating point constant
  69. \def\ET{ and~} % conjunction between two section numbers
  70. \def\ETs{, and~} % conjunction between the last two of several section numbers
  71. \def\F{\defin{format}} % format definition
  72. \let\G=\ge % greater than or equal sign
  73. \def\H#1{\hbox{\rm\char"7D\tt#1}} % hexadecimal constant
  74. \let\I=\ne % unequal sign
  75. \def\J{\.{@\&}} % TANGLE's join operation
  76. \let\K=\gets % left arrow
  77. \let\L=\le % less than or equal sign
  78. \outer\def\M#1.{\MN#1.\ifon\vfil\penalty-100\vfilneg % beginning of section
  79.   \vskip12ptminus3pt\startsection\ignorespaces}
  80. \outer\def\N#1.#2.{\MN#1.\vfil\eject % beginning of starred section
  81.   \def\rhead{\uppercase{\ignorespaces#2}} % define running headline
  82.   \message{*\modno} % progress report
  83.   \edef\next{\write\cont{\Z{#2}{\modno}{\the\pageno}}}\next % to contents file
  84.   \ifon\startsection{\bf\ignorespaces#2.\quad}\ignorespaces}
  85. \def\MN#1.{\par % common code for \M, \N
  86.   {\xdef\modstar{#1}\let\*=\empty\xdef\modno{#1}}
  87.   \ifx\modno\modstar \onmaybe \else\ontrue \fi \mark{\modno}}
  88. \def\O#1{\hbox{\rm\char'23\kern-.2em\it#1\/\kern.05em}} % octal constant
  89. \def\P{\rightskip=0pt plus 100pt minus 10pt % go into Pascal mode
  90.   \sfcode`;=3000
  91.   \pretolerance 10000
  92.   \hyphenpenalty 10000 \exhyphenpenalty 10000
  93.   \global\ind=2 \1\ \unskip}
  94. \def\Q{\rightskip=0pt % get out of Pascal mode
  95.   \sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50 }
  96. \let\R=\lnot % logical not
  97. \let\S=\equiv % equivalence sign
  98. \def\T{\mathclose{\.{@\}}}} % terminate controlled comment
  99. \def\U{\note{This code is used in section}} % crossref for use of a section
  100. \def\Us{\note{This code is used in sections}} % crossref for uses of a section
  101. \let\V=\lor % logical or
  102. \let\W=\land % logical and
  103. \def\X#1:#2\X{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi % section name
  104.   \XX$\langle\,$#2{\eightrm\kern.5em#1}$\,\rangle$\XX}
  105. \def\Y{\par\yskip}
  106. \let\Z=\let % now you can \send the control sequence \Z
  107. \def\){\hbox{\.{@\$}}} % sign for string pool check sum
  108. \def\]{\hbox{\.{@\\}}} % sign for forced line break
  109. \def\=#1{\kern2pt\hbox{\vrule\vtop{\vbox{\hrule
  110.         \hbox{\strut\kern2pt\.{#1}\kern2pt}}
  111.       \hrule}\vrule}\kern2pt} % verbatim string
  112. \let\~=\ignorespaces
  113. \let\*=*
  114.  
  115. \def\onmaybe{\let\ifon=\maybe} \let\maybe=\iftrue
  116. \newif\ifon \newif\iftitle \newif\ifpagesaved
  117. \def\lheader{\mainfont\the\pageno\eightrm\qquad\rhead\hfill\title\qquad
  118.   \tensy x\mainfont\topmark} % top line on left-hand pages
  119. \def\rheader{\tensy x\mainfont\topmark\eightrm\qquad\title\hfill\rhead
  120.   \qquad\mainfont\the\pageno} % top line on right-hand pages
  121. \def\page{\box255 }
  122. \def\normaloutput#1#2#3{\ifodd\pageno\hoffset=\pageshift\fi
  123.   \shipout\vbox{
  124.     \vbox to\fullpageheight{
  125.       \iftitle\global\titlefalse
  126.       \else\hbox to\pagewidth{\vbox to10pt{}\ifodd\pageno #3\else#2\fi}\fi
  127.       \vfill#1}} % parameter #1 is the page itself
  128.   \global\advance\pageno by1}
  129.  
  130. \def\rhead{\.{WEB} OUTPUT} % this running head is reset by starred sections
  131. \def\title{} % an optional title can be set by the user
  132. \def\topofcontents{\centerline{\titlefont\title}
  133.   \vfill} % this material will start the table of contents page
  134. \def\botofcontents{\vfill} % this material will end the table of contents page
  135. \def\contentspagenumber{0} % default page number for table of contents
  136. \newdimen\pagewidth \pagewidth=6.5in % the width of each page
  137. \newdimen\pageheight \pageheight=8.7in % the height of each page
  138. \newdimen\fullpageheight \fullpageheight=9in % page height including headlines
  139. \newdimen\pageshift \pageshift=0in % shift righthand pages wrt lefthand ones
  140. \def\magnify#1{\mag=#1\pagewidth=6.5truein\pageheight=8.7truein
  141.   \fullpageheight=9truein\setpage}
  142. \def\setpage{\hsize\pagewidth\vsize\pageheight} % use after changing page size
  143. \def\contentsfile{CONTENTS} % file that gets table of contents info
  144. \def\readcontents{\input CONTENTS}
  145.  
  146. \newwrite\cont
  147. \output{\setbox0=\page % the first page is garbage
  148.   \openout\cont=\contentsfile
  149.   \global\output{\normaloutput\page\lheader\rheader}}
  150. \setpage
  151. \vbox to \vsize{} % the first \topmark won't be null
  152.  
  153. \def\ch{\note{The following sections were changed by the change file:}
  154.   \let\*=\relax}
  155. \newbox\sbox % saved box preceding the index
  156. \newbox\lbox % lefthand column in the index
  157. \def\inx{\par\vskip6pt plus 1fil % we are beginning the index
  158.   \write\cont{} % ensure that the contents file isn't empty
  159.   \closeout\cont % the contents information has been fully gathered
  160.   \output{\ifpagesaved\normaloutput{\box\sbox}\lheader\rheader\fi
  161.     \global\setbox\sbox=\page \global\pagesavedtrue}
  162.   \pagesavedfalse \eject % eject the page-so-far and predecessors
  163.   \setbox\sbox\vbox{\unvbox\sbox} % take it out of its box
  164.   \vsize=\pageheight \advance\vsize by -\ht\sbox % the remaining height
  165.   \hsize=.5\pagewidth \advance\hsize by -10pt
  166.     % column width for the index (20pt between cols)
  167.   \parfillskip 0pt plus .6\hsize % try to avoid almost empty lines
  168.   \def\lr{L} % this tells whether the left or right column is next
  169.   \output{\if L\lr\global\se